import React from 'react';
import { observer, inject } from 'mobx-react';
import { WeaErrorPage,WeaTools, WeaLocaleProvider } from 'ecCom';
// import {WeaTableNew} from 'comsMobx';
// const WeaTable = WeaTableNew.WeaTable;
import { WeaTable } from "ecCom";
import * as _ from '../../util/common';
import '../../style/formResource.less';
import { Table, Icon } from 'antd';
const getLabel = WeaLocaleProvider.getLabel;

@observer
class RelatedWorkflow extends React.Component {
    constructor(props) {
		super(props);
    }
    componentDidMount(){
        const { wfFormResourceStore,commonParam } = this.props;
        let baseParam = {};
        const range = ["requestid", "isrequest", "desrequestid", "iswfshare", "authStr", "authSignatureStr", "f_weaver_belongto_userid", "f_weaver_belongto_usertype", "isurger","nodeid", "isurger","iscowork","coworkid","agentType","agentorByAgentId"];
        range.map(key =>{
            baseParam[key] = commonParam[key];
        });
        wfFormResourceStore.setBaseParam(baseParam);
        // wfFormResourceStore.switchTab("0");
        wfFormResourceStore.loadData(commonParam)
    }
    render(){
        const { wfFormResourceStore } = this.props;
    	const menu = [
			{title:getLabel('22105',"相关流程"), key:'0'},
		];
        const { dataSource=[],allCounts=0 } = wfFormResourceStore
        const columns = [
            {
              title: "流程标题",
              dataIndex: "requestName",
              key: "requestName",
              width: "20%",
              isHtml:true
            },
            {
                title: "创建时间",
                dataIndex: "createDateTime",
                key: "createDateTime",
                width: "20%",

              },
              {
                title: "经办人",
                dataIndex: "creater",
                key: "creater",
                width: "20%",
                isHtml:true
              },
              {
                title: "经办人部门",
                dataIndex: "departmentName",
                key: "departmentName",
                width: "20%",

              },
          ];
        return (
            <div className='wf-resources' style={{background:"white"}}>
                <div className='wf-resources-tab'>
                    {
                        menu.map(t =>{
                            const isChecked = t.key == 0;
                            const _style = isChecked ? {background:'#4bb1fb', color:'#fff'} : {background:'transparent', color:'#848484'};
                            return <div className='wf-resources-tab-item' style={_style} >
                                {t.title}
                            </div>
                        }
                    )}
                </div>
                <WeaTable
                    columns={columns}
                    dataSource={dataSource}
                    pagination={{
                        showQuickJumper:true,
                        showSizeChanger:true,
                        defaultCurrent:1,
                        showTotal:total => `总共有 ${allCounts} 流程`
                    }}
                />
            </div>
        )
    }
}

export default WeaTools.tryCatch(React, 
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@pqmoff`} msg={ props.error ? props.error : getLabel(383324,'对不起，该页面异常，请联系管理员')} />,
    {error: ""}
)(RelatedWorkflow);
